package com.husd.framework.ddl_new;

import com.alibaba.fastjson.JSON;
import com.husd.framework.ddl.DDL;

import java.util.List;

/**
 * @author shengdonghu@126.com
 * @date 2024/1/19 16:51
 */
public class MySQLTableSplitMain {

    public static void main(String[] args) {

        String str = "CREATE TEMPORARY TABLE IF NOT EXISTS `amazon_feed_log_v3` (\n" +
                "  `id` int(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID' SECONDARY_ENGINE_ATTRIBUTE=att3,\n" +
                "  `uuid` varchar(64) DEFAULT NULL COMMENT '批次号' collate collate_name GENERATED ALWAYS AS (_ge_always_as_expr * sdf) column_format FIXED ENGINE_ATTRIBUTE=att  REFERENCES customers(id1,id2) match simple on update cascade,\n" +
                "  `updated_by` varchar(50) NOT NULL DEFAULT 'RAND() * RAND()' COMMENT '修改人' ENGINE_ATTRIBUTE att2 REFERENCES customers(id1,id2,id3) match full on delete set null CONSTRAINT ssss CHECK (a + b - c) NOT ENFORCED,\n" +
                "  PRIMARY KEY (`id`) USING BTREE,\n" +
                "  PRIMARY KEY USING BTREE (`id`),\n" +
                "  KEY `idx_uuid` (`uuid`,'name', 'hell'),\n" +
                "  INDEX `idx_uuid_02` using hash (a,b,c),\n" +
                " FULLTEXT INDEX `idx_uuid_03` (a1,b1,c1),\n" +
                " CONSTRAINT c13 unique index `idx_uuid_04` using hash (a1,b1,c1) CONSTRAINT ssss CHECK (a + b - c) NOT ENFORCED,\n" +
                " CONSTRAINT c14 FOREIGN key `idx_uuid_05` (a1,b1,c1) REFERENCES t2 (id1,id2) match simple on delete no action on update cascade CONSTRAINT ssss CHECK (1a + 1b - 1c) ENFORCED,\n" +
                ") ENGINE=InnoDB DEFAULT CHARACTER SET utf88 index DIRECTORY='/abd/dss/sdf' ENCRYPTION y INSERT_METHOD no PACK_KEYS 0 STATS_AUTO_RECALC 1 CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='Amazon Feed接口日志' TABLESPACE tablespace_name STORAGE DISK UNION=(t1,t2,t3)" +
                " PARTITION BY linear hash (ab * sdf ) SUBPARTITION BY (YEAR(create_date))" +
                ";";
        // str = "DEFAULT '' COMMENT ";
        MySQLTable01SplitWordMySQLTable mySQLTableSplitWord = new MySQLTable01SplitWordMySQLTable(str);
        List<String> arr = mySQLTableSplitWord.split();
        MySQLTable02Parser parser = new MySQLTable02Parser(arr);
        DDL ddl = parser.parse();
        System.out.println(JSON.toJSONString(ddl));
    }
}
